const express = require('express');
const jwt = require('jsonwebtoken');
const { secret } = require('../config/jwt');

// 模拟测试路由配置
const testRoutes = () => {
  console.log('🔍 测试路由配置...\n');

  try {
    // 测试导入
    const bookshelfRoutes = require('../routes/bookshelf');
    const cartRoutes = require('../routes/cart');
    const borrowRoutes = require('../routes/borrow');

    console.log('✅ 路由文件导入成功');

    // 检查路由栈
    console.log('\n📋 Bookshelf路由栈:');
    bookshelfRoutes.stack.forEach((layer, index) => {
      console.log(`  ${index}: ${layer.name || 'middleware'} - ${layer.route ? layer.route.path : 'global'}`);
    });

    console.log('\n📋 Cart路由栈:');
    cartRoutes.stack.forEach((layer, index) => {
      console.log(`  ${index}: ${layer.name || 'middleware'} - ${layer.route ? layer.route.path : 'global'}`);
    });

    console.log('\n📋 Borrow路由栈:');
    borrowRoutes.stack.forEach((layer, index) => {
      console.log(`  ${index}: ${layer.name || 'middleware'} - ${layer.route ? layer.route.path : 'global'}`);
    });

    console.log('\n🎉 路由配置测试完成！');

  } catch (error) {
    console.error('❌ 路由测试失败:', error);
  }
};

testRoutes();
